//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.goldhuman.Common.Security;

import com.goldhuman.Common.Octets;

import java.security.MessageDigest;

public final class MD5Hash extends Security {
    private MessageDigest md5 = null;

    protected MD5Hash() {
        try {
            this.md5 = MessageDigest.getInstance("MD5");
        } catch (Exception var2) {
        }

    }

    public Object clone() {
        try {
            MD5Hash o = (MD5Hash)super.clone();
            o.md5 = (MessageDigest)this.md5.clone();
            return o;
        } catch (Exception var2) {
            return null;
        }
    }

    public Octets Update(Octets o) {
        if (this.md5 != null) {
            this.md5.update(o.array(), 0, o.size());
        }

        return o;
    }

    public Octets Final(Octets digest) {
        if (this.md5 != null) {
            digest.replace(this.md5.digest());
        }

        return digest;
    }

    public static Octets Digest(Octets o) {
        try {
            return new Octets(MessageDigest.getInstance("MD5").digest(o.getBytes()));
        } catch (Exception var2) {
            return new Octets();
        }
    }
}
